
<template>
  <div>
    <fundation-header :title="'购买'"></fundation-header>
    <div class='mainbuy'>
      <group gutter="0">
        <cell-box :border-intent="false" class="firstCellbox">
          <div class="infoTitle">
            <p>{{fundationInfo.name}}</p>
            <div class="detailInfo"><span>月涨跌幅{{fundationInfo.increase}}</span><span>最新净值{{fundationInfo.lastValue}}</span></div>
          </div>
        </cell-box>

      </group>
      <group gutter="0.2rem">
        <cell class="cell" title="付款账号" value="6214*******666" @click.native="cardListSelected" is-link @cell-default-arrow-color="'#000'"></cell>
        <cell  class="cell" title="账户余额" >{{balanceNum}}元</cell>
      </group>
      <div class="moneyDiv">
        <div class="inputTip">
          <span >请输入购买金额</span>
          <span  class="alertTip" v-if="showTip"><img src="../../assets/img/Fundation/icon_tip.png" class="tipImg"/>账户余额不足</span>
        </div>
          <x-input title="￥"  :type="'number'" placeholder="50000.00元起购" class="moneyInput" @on-change="vertify" v-model="money"></x-input>
          <div  class="introduct" @click="dealIntroduce">交易说明</div>
      </div>
        <x-button @click.native="next" plain type="primary" class="sure" :class="{'forbiden':isSubmit == false}" :disabled="isSubmit==false">下一步</x-button>
        <!-- <x-button @click.native="next" plain type="primary" class="sure">测试</x-button> -->
    </div>
  </div>
</template>

<script>
import {Cell, Group, CellBox} from 'vux'
import FundationHeader from './fundationHeader'
export default {
  components: {
    Group,
    Cell,
    CellBox,
    FundationHeader
  },
  data () {
    return {
      fundationInfo: {
        name: '国泰民安增利债券型发起式C', // 基金名称
        lastValue: '1.0023', // 最新净值
        increase: '5%' // 最新涨幅
      },
      balanceNum: '20000', // 余额
      money: '', // 输入的金额
      showTip: false, // 是否提示余额不足
      isSubmit: false // 标识下一步按钮是否可用

    }
  },
  created () {

  },
  methods: {
    // 选择卡片的方法
    cardListSelected () {
      console.log('选择卡片')
    },
    clearInput () {
      this.money = ''
      this.showTip = false
    },
    dealIntroduce () {
      console.log('点击跳转到说明')
      this.$router.push({name: 'fundationProductDetail'})
    },
    next () {
      this.$router.push({name: 'fundationConfirm'})
    },
    vertify () {
      // 检验金额
      let maxMoney = parseFloat(this.balanceNum)
      if (this.money > 0) {
        this.isSubmit = true
      } else {
        this.isSubmit = false
      }
      if (this.money > maxMoney) {
        this.showTip = true
      } else {
        this.showTip = false
      }
    }
  }
}
</script>

<style  lang="less" scoped>
    .cell{
      font-size: 0.28rem;
      padding: 0px 0.29rem 0px 0.31rem;
      color: #333;
      height: 0.9rem;
    }
   .cellContainer{
      margin:0;
      height: 5rem;
    }
    .infoTitle{
      width:100%;
      height:1.69rem;
      background:rgba(61,71,123,1);
      color: #fff;
    }
    .firstCellbox{
      padding: 0;
    }
    .infoTitle p{
      padding: 0.4rem 0 0.4rem 0.32rem;
      font-size: 0.27rem;
    }
    .detailInfo{
      line-height: 0.23rem;
    }
    .detailInfo span{
      box-sizing: border-box;
        display: inline-block;
        width: 50%;
        text-align: center;
        font-size: 0.23rem;
    }
    .detailInfo span:first-child{
      border-right: 1px solid #EAEAEA;
    }
    .tipImg{
      width: 0.32rem;
      height: 0.32rem;
      vertical-align: middle;
      margin-top: -0.1rem;
      margin-left: 0.3rem;
    }
     .inputTip{
      font-size: 0.22rem;
      height: 0.61rem;
      line-height: 0.61rem;
      margin-left: 0.29rem;
    }
    .alertTip{
      color:#EC1B30;
    }
    .moneyInput{
      overflow: hidden;
      height: 1.4rem;
      font-size: 0.35rem;
      padding-left: 0.32rem;
      background: #ffffff;
      padding-top: 0rem;
      padding-bottom: 0rem;
  }
  .introduct{
    border-top: 1px solid #EAEAEA;
    background: #ffffff;
    font-size: 0.24rem;
    color: #6666FF;
    height: 0.9rem;
    padding: 0 0 0 0.3rem;
    line-height: 0.9rem;
  }
  .sure{
    line-height:0.88rem;
    width:6.9rem;
    margin-left: 0.3rem;
    margin-top: 0.49rem;
    background: #EC1B30;
    font-size: 0.3rem;
    border-radius: 0.06rem;
    color: white;
    border-width: 0rem;
    &.forbiden{
      opacity: .5;
    }
  }
</style>
